﻿#include <iostream>
#include <string.h>
#include "binsearch.h"

using namespace std;
/***************搜索二叉树的测试，按元素输入的顺序建立搜索二叉树********************/
void testbstree()
{
    int i;
    //int a[20] = {13,2,7,11,10,6,3,18,15,1,4,5,8,19,16,14,17,9,12,20};
    int a[10] = {13,2,7,11,10,6,3,18,15,1};
    BinarySearchTree<int> b;
    for (i = 0; i < 20; i++)
    {
        b.InsertBST(a[i]);
    }
//    b.DeleteBST(b.Root(), 93);  //删除93的结点

//    cout <<"tree node count: " << b.size() << endl;
//    cout <<"tree deep      : " << b.Treedepth(b.Root()) << endl;

//    BinaryTreeNode <int> *f = NULL;
//    BinaryTreeNode <int> *result = NULL;
//    // 根据内容查找到该节点的指针
//    bool bOk = b.SearchBST(b.Root(),18,f,result);
//    if(bOk)
//    {
//        result->print();
//    }

    b.PostOrderTraversalStack(b.Root());
}

void testOutOfRange()
{
    int a = 5;
    char str[10] = {0};
    strcpy(str,"123456789123");
    printf("str = %s\n",str);
    printf("a = %d\n",a);
}

int main()
{
    cout << "**************create binary search tree*************" << endl;
    //testbstree();

    testOutOfRange();
    return 0;
}
